from pymilvus import MilvusClient
import face_recognition

client = MilvusClient(
    uri="http://localhost:19530",
    db_name="face_db"
)

user_id = 2111602021
image = face_recognition.load_image_file("../images/wx.jpg")
face_locations = face_recognition.face_locations(image)
if len(face_locations) != 1:
    print('没有或出现多张人脸！！！')
    exit()
face_encoding = face_recognition.face_encodings(image, face_locations)[0]

data=[
    {"user_id": user_id, "face_info": face_encoding}
]

res = client.insert(
    collection_name="face_collection",
    data=data
)

print(res)
